#pragma once
#include <fmod.hpp>
#include <fmod_event.hpp>
#include <fmod_errors.h>
#include <Windowsx.h>
#include <windows.h>
#include "InputManager.h"
#include <iostream>
#include <fstream>

class SoundTask : public sigslot::has_slots<>
{
public:

	enum SoundEvent {
		WALK_GRAVEL,
		SWORD,
		COLLISION,
		EXPLOSION
	};

	SoundTask(void);
	~SoundTask(void);
	
	bool execute(double delta);

	void keyDown(const InputEvent& e);
	
	// Sound Stuff.
	void init();

	// Spielt das Schwert ab
	void launchSound(char* sound);

protected:
	// Message Stuff.
	bool shutDown;
	int lastTime;

	// Sound Stuff.
	//FMOD::System* system;
	FMOD::EventSystem* eventsystem;
	FMOD::EventProject* eventproject;
	FMOD::MusicSystem* musicsystem;
	FMOD::Event* soundEvent[10];
	FMOD::MusicPrompt* musicPrompt;
	FMOD::EventParameter* cycle;

	void ERRCHECK(FMOD_RESULT result)
	{
		//output error message

		//if (result != FMOD_OK)    {
		//	char err[256];
		//	sprintf(err, "FMOD error! (%d) %s\n", result, );
		//	myLog->logMessage(err, Ogre::LML_NORMAL,false);
		//	
		//	if(result != 23)
		//		exit(result);
		//}
		std::fstream log("fmod_error.log",std::ios::out);
		log << FMOD_ErrorString(result) << std::endl;
		log.close();

		if (result != FMOD_OK)
			exit(result);
	};


};

